package com.cloud.recyclervieweffectdemo.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.cloud.recyclervieweffectdemo.R
import com.cloud.recyclervieweffectdemo.bean.EffectBean

/**
 * @author: njb
 * @date:   2024/12/10 23:14
 * @desc:   描述
 */
class EffectAdapter(private val dataList: MutableList<EffectBean>) : RecyclerView.Adapter<EffectAdapter.EffectViewHolder>() {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): EffectViewHolder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.item_effect,parent,false)
        return EffectViewHolder(view)

    }

    override fun getItemCount(): Int {
        return dataList.size
    }

    override fun onBindViewHolder(holder: EffectViewHolder, position: Int) {
        val data = dataList[position]
        holder.textView.text = data.name
    }

    class EffectViewHolder(itemView: View) :RecyclerView.ViewHolder(itemView){
        val textView:TextView = itemView.findViewById(R.id.tv_name)
        val ivAvatar:ImageView = itemView.findViewById(R.id.iv_avatar)
    }
}